home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / esc.jar / com / extensibility / xml / DTDParser.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-06-30  |  28.2 KB  |  1,883 lines

  1. package com.extensibility.xml;
  2.  
  3. import com.extensibility.util.Debug;
  4. import com.extensibility.util.StringUtilities;
  5. import java.io.EOFException;
  6. import java.io.FileNotFoundException;
  7. import java.io.IOException;
  8. import java.net.MalformedURLException;
  9. import java.net.URL;
  10. import java.util.Enumeration;
  11. import java.util.Hashtable;
  12. import java.util.Stack;
  13. import java.util.Vector;
  14.  
  15. public final class DTDParser {
  16.    Stack sectionStack = new Stack();
  17.    Stack readerStack = new Stack();
  18.    ReaderContext readerContext;
  19.    DTDParserFactoryIntf factory;
  20.    char parseChar;
  21.    Hashtable internalGEs = new Hashtable();
  22.    Hashtable externalGEs = new Hashtable();
  23.    boolean sgml;
  24.    boolean signalEOF;
  25.    StringBuffer currentSyntax;
  26.    StringBuffer ignoredText;
  27.    boolean autoInsertPEs;
  28.    boolean autoInsertGEs;
  29.    ReaderContext peStart;
  30.    long totalCharsToParse;
  31.    long charsParsedSoFar;
  32.    boolean inParser;
  33.    URI documentURI;
  34.    private ParserException dummyError;
  35.    boolean extendedModelSytax;
  36.    static final int[] KLEENE_1 = new int[]{1, 1};
  37.    static final int[] KLEENE_PLUS = new int[]{1, Integer.MAX_VALUE};
  38.    static final int[] KLEENE_QUESTION = new int[]{0, 1};
  39.    static final int[] KLEENE_STAR = new int[]{0, Integer.MAX_VALUE};
  40.    private static final int SDATA = 1;
  41.    private static final int CDATA = 2;
  42.    // $FF: renamed from: PI int
  43.    private static final int field_0 = 3;
  44.    private static final int STARTTAG = 4;
  45.    private static final int ENDTAG = 5;
  46.    // $FF: renamed from: MD int
  47.    private static final int field_1 = 6;
  48.    // $FF: renamed from: MS int
  49.    private static final int field_2 = 7;
  50.  
  51.    public static boolean isName(String var0) {
  52.       if (var0 != null && var0.length() != 0) {
  53.          int var1 = 0;
  54.          if (var0.charAt(0) == '%' && var0.length() > 1) {
  55.             ++var1;
  56.          } else if (var0.charAt(0) == '&' && var0.length() > 1) {
  57.             ++var1;
  58.          }
  59.  
  60.          if (!isNameStartChar(var0.charAt(var1))) {
  61.             return false;
  62.          } else {
  63.             for(int var2 = var1 + 1; var2 < var0.length(); ++var2) {
  64.                if (!isNameChar(var0.charAt(var2))) {
  65.                   return var0.charAt(var2) == ';' && var2 == var0.length() - 1;
  66.                }
  67.             }
  68.  
  69.             return true;
  70.          }
  71.       } else {
  72.          return false;
  73.       }
  74.    }
  75.  
  76.    public static boolean isNmToken(String var0) {
  77.       if (var0 != null && var0.length() != 0) {
  78.          for(int var1 = 0; var1 < var0.length(); ++var1) {
  79.             if (!isNameChar(var0.charAt(var1)) && (var0.charAt(var1) != '%' || var1 != 0) && (var0.charAt(var1) != '&' || var1 != 0) && (var0.charAt(var1) != ';' || var1 != var0.length() - 1)) {
  80.                return false;
  81.             }
  82.          }
  83.  
  84.          return true;
  85.       } else {
  86.          return false;
  87.       }
  88.    }
  89.  
  90.    public static boolean isNames(String var0) {
  91.       try {
  92.          Vector var1 = DTDUtilities.parseNameList(var0, '\u0000');
  93.  
  94.          for(int var5 = 0; var5 < var1.size(); ++var5) {
  95.             if (!isName((String)var1.elementAt(var5))) {
  96.                boolean var3 = false;
  97.                return var3;
  98.             }
  99.          }
  100.  
  101.          return true;
  102.       } catch (ParserException var4) {
  103.          boolean var2 = false;
  104.          return var2;
  105.       }
  106.    }
  107.  
  108.    public static boolean isNmTokens(String var0) {
  109.       try {
  110.          Vector var1 = DTDUtilities.parseNameList(var0, '\u0000');
  111.  
  112.          for(int var5 = 0; var5 < var1.size(); ++var5) {
  113.             if (!isNmToken((String)var1.elementAt(var5))) {
  114.                boolean var3 = false;
  115.                return var3;
  116.             }
  117.          }
  118.  
  119.          return true;
  120.       } catch (ParserException var4) {
  121.          boolean var2 = false;
  122.          return var2;
  123.       }
  124.    }
  125.  
  126.    public static boolean isNameChar(char var0) {
  127.       return var0 >= 'A' && var0 <= 'Z' || var0 >= 'a' && var0 <= 'z' || var0 >= '0' && var0 <= '9' || var0 == '-' || var0 == '_' || var0 == '.' || var0 == ':' || var0 >= 192 && var0 <= 214 || var0 >= 216 && var0 <= 246 || var0 >= 248 && var0 <= 255 || var0 > 255;
  128.    }
  129.  
  130.    public static boolean isPubId(String var0) {
  131.       for(int var1 = 0; var1 < var0.length(); ++var1) {
  132.          if (!isPubIDChar(var0.charAt(var1))) {
  133.             return false;
  134.          }
  135.       }
  136.  
  137.       return true;
  138.    }
  139.  
  140.    public static boolean isPubIDChar(char var0) {
  141.       return true;
  142.    }
  143.  
  144.    public static boolean isNameStartChar(char var0) {
  145.       return var0 >= 'A' && var0 <= 'Z' || var0 >= 'a' && var0 <= 'z' || var0 == '_' || var0 == ':' || var0 >= 192 && var0 <= 214 || var0 >= 216 && var0 <= 246 || var0 >= 248 && var0 <= 255 || var0 > 255;
  146.    }
  147.  
  148.    public static boolean isOccuranceChar(char var0) {
  149.       return var0 == '?' || var0 == '+' || var0 == '*';
  150.    }
  151.  
  152.    public static boolean isDigitChar(char var0) {
  153.       return var0 >= '0' && var0 <= '9';
  154.    }
  155.  
  156.    public static boolean isWhiteChar(char var0) {
  157.       return var0 == ' ' || var0 == '\t' || var0 == '\r' || var0 == '\n';
  158.    }
  159.  
  160.    public static boolean isConnectorChar(char var0) {
  161.       return var0 == ',' || var0 == '|';
  162.    }
  163.  
  164.    public static boolean isWhiteString(String var0) {
  165.       for(int var1 = 0; var1 < var0.length(); ++var1) {
  166.          if (!isWhiteChar(var0.charAt(var1))) {
  167.             return false;
  168.          }
  169.       }
  170.  
  171.       return true;
  172.    }
  173.  
  174.    public final boolean isSGML() {
  175.       return this.sgml;
  176.    }
  177.  
  178.    public final void setExtendedModelSyntax(boolean var1) {
  179.       this.extendedModelSytax = var1;
  180.    }
  181.  
  182.    public final boolean supportsExtendedModelSyntax() {
  183.       return this.extendedModelSytax;
  184.    }
  185.  
  186.    public void setSGML(boolean var1) {
  187.       this.sgml = var1;
  188.    }
  189.  
  190.    public DTDParser(URI var1, DTDParserFactoryIntf var2, boolean var3) throws IOException {
  191.       this.internalGEs.put("lt", "&#60;");
  192.       this.internalGEs.put("gt", ">");
  193.       this.internalGEs.put("amp", "&#38;");
  194.       this.internalGEs.put("apos", "'");
  195.       this.internalGEs.put("quot", """);
  196.       this.sgml = false;
  197.       this.signalEOF = true;
  198.       this.currentSyntax = new StringBuffer();
  199.       this.autoInsertPEs = true;
  200.       this.autoInsertGEs = false;
  201.       this.peStart = null;
  202.       this.totalCharsToParse = -1L;
  203.       this.charsParsedSoFar = 0L;
  204.       this.inParser = false;
  205.       this.dummyError = new ParserException(0, ' ');
  206.       this.extendedModelSytax = false;
  207.       this.documentURI = var1;
  208.       this.factory = var2;
  209.       this.totalCharsToParse = var1.getLength();
  210.       this.sgml = var3;
  211.       this.readerContext = new ReaderContext(1, var1);
  212.    }
  213.  
  214.    private DTDParser(String var1, DTDParserFactoryIntf var2) {
  215.       this.internalGEs.put("lt", "&#60;");
  216.       this.internalGEs.put("gt", ">");
  217.       this.internalGEs.put("amp", "&#38;");
  218.       this.internalGEs.put("apos", "'");
  219.       this.internalGEs.put("quot", """);
  220.       this.sgml = false;
  221.       this.signalEOF = true;
  222.       this.currentSyntax = new StringBuffer();
  223.       this.autoInsertPEs = true;
  224.       this.autoInsertGEs = false;
  225.       this.peStart = null;
  226.       this.totalCharsToParse = -1L;
  227.       this.charsParsedSoFar = 0L;
  228.       this.inParser = false;
  229.       this.dummyError = new ParserException(0, ' ');
  230.       this.extendedModelSytax = false;
  231.       URI var3 = URI.makeStringURI(var1);
  232.       this.documentURI = var3;
  233.       this.factory = var2;
  234.       this.totalCharsToParse = var3.getLength();
  235.       this.sgml = false;
  236.  
  237.       try {
  238.          this.readerContext = new ReaderContext(1, var3);
  239.       } catch (Exception var5) {
  240.       }
  241.  
  242.    }
  243.  
  244.    public void parse() throws IOException {
  245.       this.inParser = true;
  246.       this.factory.parseBegun(this);
  247.  
  248.       while(true) {
  249.          this.currentSyntax.setLength(0);
  250.  
  251.          label106: {
  252.             try {
  253.                if (this.parseChar != '<') {
  254.                   this.autoInsertPEs = false;
  255.                   this.skipWhite();
  256.                }
  257.             } catch (ParserException var9) {
  258.                if (var9.getOriginal() != null && !this.isRecoverableException(var9.getOriginal())) {
  259.                   if (!(var9.getOriginal() instanceof EOFException)) {
  260.                      this.parseError(var9, true);
  261.                      this.inParser = false;
  262.                      throw (IOException)var9.getOriginal();
  263.                   }
  264.                   break label106;
  265.                }
  266.  
  267.                this.parseError(var9, true);
  268.             } finally {
  269.                this.autoInsertPEs = true;
  270.             }
  271.  
  272.             try {
  273.                this.parseExtSubsetDecl();
  274.                continue;
  275.             } catch (ParserException var8) {
  276.                this.parseError(var8, true);
  277.                if (this.isRecoverableException(var8.getOriginal())) {
  278.                   continue;
  279.                }
  280.  
  281.                if (!(var8.getOriginal() instanceof EOFException)) {
  282.                   this.inParser = false;
  283.                   this.factory.parseEnded(this);
  284.                   throw (IOException)var8.getOriginal();
  285.                }
  286.             }
  287.          }
  288.  
  289.          this.inParser = false;
  290.          this.factory.parseEnded(this);
  291.          return;
  292.       }
  293.    }
  294.  
  295.    private boolean isRecoverableException(Exception var1) {
  296.       if (var1 == null) {
  297.          return true;
  298.       } else if (var1 instanceof FileNotFoundException) {
  299.          return true;
  300.       } else if (var1 instanceof IOException) {
  301.          return false;
  302.       } else {
  303.          Debug.assert(var1);
  304.          return false;
  305.       }
  306.    }
  307.  
  308.    private void parseError(ParserException var1, boolean var2) {
  309.       int var3 = this.currentSyntax.length();
  310.       if (var2) {
  311.          try {
  312.             for(this.autoInsertPEs = false; this.parseChar != -1 && this.parseChar != '>' && this.parseChar != '<'; this.read()) {
  313.                if (this.isSGML() && this.tryRead("--")) {
  314.                   this.parseUntil("--");
  315.                }
  316.             }
  317.          } catch (ParserException var9) {
  318.          } finally {
  319.             this.autoInsertPEs = true;
  320.          }
  321.  
  322.          if (this.parseChar == '<') {
  323.             this.currentSyntax.setLength(this.currentSyntax.length() - 1);
  324.          }
  325.       }
  326.  
  327.       this.trimWhite(this.currentSyntax);
  328.       var1.setSource(this.currentSyntax.toString());
  329.       var1.setSourcePos(var3);
  330.       var1.setSourceLinePos(this.readerContext.getLine());
  331.       var1.setContext(this.readerContext, this.readerStack);
  332.       this.factory.createError(var1);
  333.    }
  334.  
  335.    public void parseExtSubsetDecl() throws ParserException {
  336.       this.currentSyntax.setLength(1);
  337.       this.currentSyntax.setCharAt(0, this.parseChar);
  338.       switch (this.parseChar) {
  339.          case '%':
  340.             this.parsePEReference(true);
  341.             break;
  342.          case '<':
  343.             this.parseMarkupDecl();
  344.             break;
  345.          case ']':
  346.             this.read();
  347.             if (this.parseChar != ']') {
  348.                throw new ParserException(63, this.parseChar);
  349.             }
  350.  
  351.             this.read();
  352.             if (this.parseChar != '>') {
  353.                throw new ParserException(63, this.parseChar);
  354.             }
  355.  
  356.             String var1 = this.sectionStack.isEmpty() ? "" : (String)this.sectionStack.pop();
  357.             if (this.isCondition(var1)) {
  358.                this.factory.createConditionalClose(this.readerContext.getURI(), this.getAndResetIgnoredText());
  359.             }
  360.             break;
  361.          default:
  362.             throw new ParserException(31, this.parseChar);
  363.       }
  364.  
  365.    }
  366.  
  367.    private String getAndResetIgnoredText() {
  368.       if (this.sectionStack != null && this.ignoredText != null) {
  369.          for(int var1 = 0; var1 < this.sectionStack.size(); ++var1) {
  370.             String var2 = (String)this.sectionStack.elementAt(var1);
  371.             if (this.isIgnore(var2)) {
  372.                return null;
  373.             }
  374.          }
  375.  
  376.          String var3 = this.ignoredText.toString();
  377.          this.ignoredText = null;
  378.          return var3;
  379.       } else {
  380.          return null;
  381.       }
  382.    }
  383.  
  384.    private boolean isCondition(ReaderContext var1) {
  385.       return this.isCondition(StringUtilities.trimTrailingWhitespace(var1.getValue()));
  386.    }
  387.  
  388.    private boolean isIgnore(String var1) {
  389.       return var1.equals("IGNORE");
  390.    }
  391.  
  392.    private boolean isCondition(String var1) {
  393.       if (this.isSGML()) {
  394.          var1 = var1.toUpperCase();
  395.       }
  396.  
  397.       return var1.equals("IGNORE") || var1.equals("INCLUDE");
  398.    }
  399.  
  400.    void parseMarkupDecl() throws ParserException {
  401.       this.read();
  402.       switch (this.parseChar) {
  403.          case '!':
  404.             this.read();
  405.             switch (this.parseChar) {
  406.                case '-':
  407.                   this.read();
  408.                   if (this.parseChar != '-') {
  409.                      throw new ParserException(16, this.parseChar);
  410.                   }
  411.  
  412.                   this.parseComment();
  413.                   return;
  414.                case '[':
  415.                   this.skipWhite();
  416.                   Object var1 = null;
  417.                   String var2 = null;
  418.                   String var4;
  419.                   if (this.peStart != null && this.isCondition(this.peStart)) {
  420.                      var4 = StringUtilities.trimTrailingWhitespace(this.peStart.getValue());
  421.                      var2 = this.peStart.getName();
  422.                      this.popReaderContext(this.peStart, true);
  423.                      this.peStart = null;
  424.                      this.checkWhite();
  425.                   } else {
  426.                      var4 = StringUtilities.trimTrailingWhitespace(this.parseCaps());
  427.                   }
  428.  
  429.                   var4 = var4.toUpperCase();
  430.                   this.sectionStack.push(var4);
  431.                   if (!this.isCondition(var4)) {
  432.                      throw new ParserException(61, var4);
  433.                   }
  434.  
  435.                   this.factory.createConditionalOpen(var4, var2, this.readerContext.getURI());
  436.                   this.checkWhite();
  437.                   if (this.parseChar != '[') {
  438.                      throw new ParserException(62, this.parseChar);
  439.                   }
  440.  
  441.                   if (this.isIgnore(var4) && this.ignoredText == null) {
  442.                      this.ignoredText = new StringBuffer();
  443.                   }
  444.  
  445.                   return;
  446.                default:
  447.                   if (this.peStart != null) {
  448.                   }
  449.  
  450.                   String var3 = this.parseCaps();
  451.                   if (var3.equals("ELEMENT")) {
  452.                      this.parseElementDecl();
  453.                   } else if (var3.equals("ATTLIST")) {
  454.                      this.parseAttListDecl();
  455.                   } else if (var3.equals("ENTITY")) {
  456.                      this.parseEntityDecl();
  457.                   } else {
  458.                      if (!var3.equals("NOTATION")) {
  459.                         throw new ParserException(30, var3);
  460.                      }
  461.  
  462.                      this.parseNotationDecl();
  463.                   }
  464.  
  465.                   if (this.isSGML() && this.parseChar == '-') {
  466.                      this.parseInlineComment(false);
  467.                   }
  468.  
  469.                   if (this.checkWhite() != '>') {
  470.                      throw new ParserException(29, this.parseChar);
  471.                   }
  472.  
  473.                   return;
  474.             }
  475.          case '?':
  476.             this.parsePI();
  477.       }
  478.  
  479.    }
  480.  
  481.    boolean inIgnoreSection() {
  482.       return this.ignoredText != null;
  483.    }
  484.  
  485.    String parseGEReference(boolean var1, boolean var2) throws ParserException {
  486.       this.read();
  487.       if (this.isSGML()) {
  488.          this.checkWhite();
  489.       }
  490.  
  491.       String var3 = this.parseName();
  492.       if (this.inIgnoreSection()) {
  493.          this.ignoredText.append('&');
  494.          this.ignoredText.append(var3);
  495.          this.ignoredText.append(';');
  496.          return var3;
  497.       } else {
  498.          if (this.parseChar != ';') {
  499.             if (!this.isSGML()) {
  500.                throw new ParserException(67, this.parseChar);
  501.             }
  502.  
  503.             this.parseError(new ParserException(110, this.parseChar, 1), false);
  504.          }
  505.  
  506.          String var4;
  507.          if (var3.charAt(0) == '#') {
  508.             if (var3.length() <= 2) {
  509.                throw new ParserException(66, var3);
  510.             }
  511.  
  512.             int var5;
  513.             try {
  514.                if (var3.charAt(1) == 'x') {
  515.                   var5 = Integer.parseInt(var3.substring(2, var3.length()), 16);
  516.                } else {
  517.                   var5 = Integer.parseInt(var3.substring(1, var3.length()));
  518.                }
  519.             } catch (NumberFormatException var7) {
  520.                throw new ParserException(66, var3);
  521.             }
  522.  
  523.             var4 = (new Character((char)var5)).toString();
  524.          } else if (var1) {
  525.             if (!var2) {
  526.                throw new ParserException(66, var3);
  527.             }
  528.  
  529.             var4 = String.valueOf(String.valueOf("&").concat(String.valueOf(var3))).concat(String.valueOf(this.parseChar));
  530.          } else {
  531.             var4 = (String)this.internalGEs.get(var3);
  532.          }
  533.  
  534.          if (var4 == null) {
  535.             throw new ParserException(68, var3);
  536.          } else {
  537.             this.saveErrorContext();
  538.             this.readerStack.push(this.readerContext);
  539.             this.readerContext = new ReaderContext(var4, 2, var3, var4, this.readerContext.getURI());
  540.             return var3;
  541.          }
  542.       }
  543.    }
  544.  
  545.    private void saveErrorContext() {
  546.       if (this.readerContext.getType() == 1) {
  547.          this.dummyError.setSourceLinePos(this.readerContext.getLine());
  548.          this.dummyError.setContext(this.readerContext, this.readerStack);
  549.       }
  550.  
  551.    }
  552.  
  553.    protected boolean isInReaderStack(URI var1) {
  554.       for(int var2 = 0; var2 < this.readerStack.size(); ++var2) {
  555.          ReaderContext var3 = (ReaderContext)this.readerStack.elementAt(var2);
  556.          if (var3.getURI().equals(var1)) {
  557.             return true;
  558.          }
  559.       }
  560.  
  561.       return false;
  562.    }
  563.  
  564.    String parsePEReference(boolean var1) throws ParserException {
  565.       this.read();
  566.       if (this.isSGML()) {
  567.          this.checkWhite();
  568.       }
  569.  
  570.       String var2 = this.parseName();
  571.       boolean var3 = !var1;
  572.       if (this.inIgnoreSection()) {
  573.          this.ignoredText.append('%');
  574.          this.ignoredText.append(var2);
  575.          this.ignoredText.append(';');
  576.          return var2;
  577.       } else {
  578.          if (this.parseChar != ';') {
  579.             if (!this.isSGML()) {
  580.                throw new ParserException(67, this.parseChar);
  581.             }
  582.  
  583.             this.parseError(new ParserException(110, this.parseChar, 0), false);
  584.  
  585.             try {
  586.                this.parseChar = (char)this.readerContext.unread(this.parseChar);
  587.             } catch (EOFException var10) {
  588.                throw new ParserException(var10, var2);
  589.             }
  590.          }
  591.  
  592.          String var4 = this.factory.getPE(true, var2);
  593.          String var6 = "";
  594.          if (var4 != null) {
  595.             this.saveErrorContext();
  596.             this.readerStack.push(this.readerContext);
  597.             this.readerContext = new ReaderContext(String.valueOf(String.valueOf(" ").concat(String.valueOf(var4))).concat(String.valueOf(" ")), 4, var2, var4, this.readerContext.getURI());
  598.          } else if (var3) {
  599.             this.saveErrorContext();
  600.             this.readerStack.push(this.readerContext);
  601.             this.readerContext = new ReaderContext("", 4, var2, "", this.readerContext.getURI());
  602.             this.parseError(new ParserException(69, var2), false);
  603.          } else {
  604.             var6 = this.factory.getPE(false, var2);
  605.             if (var6 == null) {
  606.                throw new ParserException(69, var2);
  607.             }
  608.  
  609.             if (var6.length() == 0) {
  610.                this.parseError(new ParserException(88, var2), false);
  611.             } else {
  612.                URI var7 = this.readerContext.getURI();
  613.                URI var8 = new URI(var7, var6);
  614.                if (this.isInReaderStack(var8)) {
  615.                   throw new ParserException(98, var6);
  616.                }
  617.  
  618.                this.totalCharsToParse += var8.getLength();
  619.  
  620.                try {
  621.                   ReaderContext var9 = new ReaderContext(var8, 5, var2, var8);
  622.                   this.readerStack.push(this.readerContext);
  623.                   this.readerContext = var9;
  624.                   this.factory.createExternalSubsetOpen(var2, var8, var7);
  625.                } catch (Exception var11) {
  626.                   this.parseError(var11 instanceof ParserException ? (ParserException)var11 : new ParserException(var11, var6), false);
  627.                   this.factory.createExternalSubsetOpen(var2, var8, var7);
  628.                   this.factory.createExternalSubsetClose();
  629.                }
  630.             }
  631.          }
  632.  
  633.          this.read();
  634.          return var2;
  635.       }
  636.    }
  637.  
  638.    void parsePI() throws ParserException {
  639.       this.skipWhite();
  640.       String var1 = this.parseName();
  641.       String var2 = this.parseUntil(this.isSGML() ? ">" : "?>");
  642.       if (var1.equals("xml")) {
  643.          Object var3 = null;
  644.  
  645.          try {
  646.             var7 = XMLStringUtilities.getNameValuePairs(var2);
  647.          } catch (Exception var6) {
  648.             throw new ParserException(275, var2);
  649.          }
  650.  
  651.          if (var7 != null) {
  652.             if (var7.containsKey("encoding")) {
  653.                String var4 = (String)var7.get("encoding");
  654.                this.factory.setEncoding(var4);
  655.                if (!XMLReader.supportsEncoding(var4)) {
  656.                   throw new ParserException(274, var4, 1);
  657.                }
  658.             }
  659.  
  660.             Enumeration var8 = var7.keys();
  661.  
  662.             while(var8.hasMoreElements()) {
  663.                String var5 = (String)var8.nextElement();
  664.                if (!var5.equals("encoding")) {
  665.                   this.parseError(new ParserException(999, String.valueOf("All attributes but 'encoding' dropped from 'xml' PI; found: ").concat(String.valueOf(var5))), false);
  666.                }
  667.             }
  668.          }
  669.       } else if (var1.toLowerCase().startsWith("xml")) {
  670.          this.factory.createPI(var1, var2, this.readerContext.getURI());
  671.          this.parseError(new ParserException(273, var1, 1), false);
  672.       } else {
  673.          this.factory.createPI(var1, var2, this.readerContext.getURI());
  674.       }
  675.  
  676.    }
  677.  
  678.    void parseComment() throws ParserException {
  679.       this.autoInsertPEs = false;
  680.  
  681.       try {
  682.          if (this.isSGML()) {
  683.             while(true) {
  684.                String var6 = this.parseUntil("--");
  685.                this.factory.createComment(var6);
  686.                this.skipWhite();
  687.                if (this.parseChar == '>') {
  688.                   break;
  689.                }
  690.  
  691.                if (!this.tryRead("--")) {
  692.                   throw new ParserException(130, this.parseChar);
  693.                }
  694.             }
  695.          } else {
  696.             String var1 = this.parseUntil("-->");
  697.             this.factory.createComment(var1);
  698.          }
  699.       } finally {
  700.          this.autoInsertPEs = true;
  701.       }
  702.  
  703.    }
  704.  
  705.    void parseElementDecl() throws ParserException {
  706.       Vector var1 = null;
  707.       this.skipWhite();
  708.       String var2;
  709.       if (this.isSGML() && this.parseChar == '(') {
  710.          var1 = this.parseNameList();
  711.          var2 = (String)var1.firstElement();
  712.       } else {
  713.          var2 = this.parseName();
  714.       }
  715.  
  716.       this.checkWhite(true);
  717.       if (this.peStart != null) {
  718.       }
  719.  
  720.       while(this.isSGML() && this.parseChar == '-' && this.tryRead("--")) {
  721.          this.parseInlineCommentInterior(true);
  722.       }
  723.  
  724.       if (this.isSGML() && (this.parseChar == '-' || this.parseChar == 'o' || this.parseChar == 'O')) {
  725.          this.skipWhite();
  726.          if (this.parseChar != '-' && this.parseChar != 'o' && this.parseChar != 'O') {
  727.             throw new ParserException(46, this.parseChar);
  728.          }
  729.  
  730.          this.skipWhite();
  731.          this.parseError(new ParserException(101, "", 0), false);
  732.       }
  733.  
  734.       this.factory.createElementDecl(var2, this.readerContext.getURI());
  735.       this.parseModel(',', true);
  736.       this.checkWhite();
  737.  
  738.       while(this.isSGML() && (this.parseChar == '-' || this.parseChar == '+')) {
  739.          if (this.parseChar == '-' && this.tryRead("--")) {
  740.             this.parseInlineCommentInterior(false);
  741.          } else {
  742.             int var3 = this.currentSyntax.length();
  743.             this.read();
  744.             this.parseParentheses();
  745.             this.parseError(new ParserException(111, this.currentSyntax.toString().substring(var3 - 1, this.currentSyntax.length()), 1), false);
  746.             this.checkWhite();
  747.          }
  748.       }
  749.  
  750.       if (this.isSGML() && var1 != null) {
  751.          for(int var4 = 1; var4 < var1.size(); ++var4) {
  752.             this.factory.cloneElementDecl(var2, (String)var1.elementAt(var4));
  753.          }
  754.  
  755.          this.parseError(new ParserException(103, var1.toString(), 0), false);
  756.       }
  757.  
  758.    }
  759.  
  760.    public static void parseModel(String var0, DTDParserFactoryIntf var1, boolean var2, boolean var3) throws ParserException {
  761.       var0 = var0.trim();
  762.       DTDParser var4 = new DTDParser(var0, var1);
  763.       var4.setExtendedModelSyntax(var2);
  764.       var4.signalEOF = false;
  765.       var4.skipWhite();
  766.       var4.parseModel(',', var3);
  767.    }
  768.  
  769.    Vector parseNameList() throws ParserException {
  770.       Vector var1 = new Vector();
  771.  
  772.       do {
  773.          this.skipWhite();
  774.          String var2 = this.parseName();
  775.          var1.addElement(var2);
  776.          this.checkWhite();
  777.       } while(this.parseChar == '|');
  778.  
  779.       if (this.parseChar != ')') {
  780.          throw new ParserException(104, this.parseChar);
  781.       } else {
  782.          this.read();
  783.          return var1;
  784.       }
  785.    }
  786.  
  787.    private int[] occRangeForKleene(char var1) {
  788.       if (var1 == 0) {
  789.          return KLEENE_1;
  790.       } else if (var1 == '+') {
  791.          return KLEENE_PLUS;
  792.       } else if (var1 == '?') {
  793.          return KLEENE_QUESTION;
  794.       } else if (var1 == '*') {
  795.          return KLEENE_STAR;
  796.       } else {
  797.          throw new IllegalArgumentException((new Character(var1)).toString());
  798.       }
  799.    }
  800.  
  801.    char parseModel(char var1, boolean var2) throws ParserException {
  802.       if (this.peStart != null) {
  803.          char var3 = this.factory.createContentTerms(this.peStart.getName(), var2, this.dummyError);
  804.          if (var3 != 0) {
  805.             this.popReaderContext(this.peStart, true);
  806.             this.peStart = null;
  807.             this.checkWhite();
  808.             return var3;
  809.          }
  810.       } else {
  811.          this.checkWhite(true);
  812.          if (this.peStart != null) {
  813.             char var13 = this.factory.createContentTerms(this.peStart.getName(), var2, this.dummyError);
  814.             if (var13 != 0) {
  815.                this.popReaderContext(this.peStart, true);
  816.                this.peStart = null;
  817.                this.checkWhite();
  818.                return var13;
  819.             }
  820.          }
  821.       }
  822.  
  823.       boolean var14 = this.parseChar == '(';
  824.       if (var2 && !var14) {
  825.          try {
  826.             this.parseModelTermConstant();
  827.             char var15 = 0;
  828.             return var15;
  829.          } catch (ParserException var12) {
  830.             this.parseError(var12, false);
  831.          }
  832.       }
  833.  
  834.       if (var14) {
  835.          this.factory.createCMOpen();
  836.          this.skipWhite(true);
  837.       }
  838.  
  839.       int[] var4 = KLEENE_1;
  840.  
  841.       try {
  842.          char var5 = ',';
  843.  
  844.          while(this.parseChar != ')') {
  845.             if (this.parseChar == '\uffff') {
  846.                char var6 = var1;
  847.                return var6;
  848.             }
  849.  
  850.             if (this.parseChar == '(') {
  851.                var5 = this.parseModel(var5, false);
  852.             } else {
  853.                var5 = this.parseModelTerm(var5);
  854.             }
  855.          }
  856.  
  857.          this.read();
  858.          if (this.supportsExtendedModelSyntax() && this.parseChar == '{') {
  859.             var4 = this.parseOccuranceRange();
  860.          } else if (this.parseChar == '?' || this.parseChar == '*' || this.parseChar == '+') {
  861.             var4 = this.occRangeForKleene(this.parseChar);
  862.             this.skipWhite();
  863.          }
  864.  
  865.          this.checkWhite();
  866.          if (this.isSGML() && this.parseChar == '&') {
  867.             this.parseError(new ParserException(102, '&', 1), false);
  868.             var1 = '|';
  869.             this.skipWhite();
  870.             return var1;
  871.          } else {
  872.             if (this.parseChar == '|' || this.parseChar == ',') {
  873.                var1 = this.parseChar;
  874.                this.skipWhite();
  875.             }
  876.  
  877.             return var1;
  878.          }
  879.       } finally {
  880.          if (var14) {
  881.             this.factory.createCMClose(var4, var1);
  882.          }
  883.  
  884.       }
  885.    }
  886.  
  887.    void parseParentheses() throws ParserException {
  888.       if (this.parseChar != '(') {
  889.          throw new ParserException(47, this.parseChar);
  890.       } else {
  891.          int var1 = 1;
  892.  
  893.          while(var1 > 0) {
  894.             this.read();
  895.             if (this.parseChar == '(') {
  896.                ++var1;
  897.             } else if (this.parseChar == ')') {
  898.                --var1;
  899.             }
  900.          }
  901.  
  902.          this.read();
  903.       }
  904.    }
  905.  
  906.    void parseModelTermConstant() throws ParserException {
  907.       String var1 = this.parseCaps();
  908.       byte var2;
  909.       if (var1.equals("ANY")) {
  910.          var2 = 2;
  911.       } else if (var1.equals("EMPTY")) {
  912.          var2 = 3;
  913.       } else {
  914.          if ((!this.isSGML() || !var1.equals("RCDATA")) && !var1.equals("CDATA")) {
  915.             if (this.isSGML()) {
  916.                throw new ParserException(45, ' ');
  917.             }
  918.  
  919.             throw new ParserException(46, ' ');
  920.          }
  921.  
  922.          var2 = 1;
  923.          this.parseError(new ParserException(112, var1, 1), false);
  924.       }
  925.  
  926.       this.factory.createCMTerm(var2);
  927.    }
  928.  
  929.    int parseDigits() throws ParserException {
  930.       String var1 = this.parseNMToken();
  931.  
  932.       try {
  933.          int var2 = Integer.parseInt(var1);
  934.          return var2;
  935.       } catch (NumberFormatException var3) {
  936.          throw new ParserException(93, var1);
  937.       }
  938.    }
  939.  
  940.    int[] parseOccuranceRange() throws ParserException {
  941.       this.skipWhite();
  942.       int var1 = this.parseDigits();
  943.       this.checkWhite();
  944.       if (this.parseChar != ',') {
  945.          throw new ParserException(93, this.parseChar);
  946.       } else {
  947.          this.skipWhite();
  948.          int var2;
  949.          if (this.parseChar == '*') {
  950.             var2 = Integer.MAX_VALUE;
  951.             this.skipWhite();
  952.          } else {
  953.             var2 = this.parseDigits();
  954.          }
  955.  
  956.          this.skipWhite();
  957.          return new int[]{var1, var2};
  958.       }
  959.    }
  960.  
  961.    char parseModelTerm(char var1) throws ParserException {
  962.       int[] var2 = KLEENE_1;
  963.       if (this.peStart != null) {
  964.          char var3 = this.factory.createContentTerms(this.peStart.getName(), false, this.dummyError);
  965.          if (var3 != 0) {
  966.             this.popReaderContext(this.peStart, true);
  967.             this.peStart = null;
  968.             this.checkWhite();
  969.             if (this.supportsExtendedModelSyntax() && this.parseChar == '{') {
  970.                var2 = this.parseOccuranceRange();
  971.             } else if (this.parseChar == '?' || this.parseChar == '*' || this.parseChar == '+') {
  972.                var2 = this.occRangeForKleene(this.parseChar);
  973.                this.skipWhite();
  974.             }
  975.  
  976.             if (this.parseChar == '|' || this.parseChar == ',') {
  977.                var3 = this.parseChar;
  978.                this.skipWhite(true);
  979.             }
  980.  
  981.             this.factory.changeTerms(var2, var3);
  982.             return var3;
  983.          }
  984.       } else {
  985.          this.checkWhite();
  986.       }
  987.  
  988.       String var4 = this.parseTermName();
  989.       if (this.supportsExtendedModelSyntax() && this.parseChar == '{') {
  990.          var2 = this.parseOccuranceRange();
  991.       } else if (this.parseChar != '?' && this.parseChar != '*' && this.parseChar != '+') {
  992.          this.checkWhite();
  993.       } else {
  994.          var2 = this.occRangeForKleene(this.parseChar);
  995.          this.skipWhite();
  996.       }
  997.  
  998.       while(this.parseChar == '-' && this.tryRead("--")) {
  999.          this.parseInlineCommentInterior(false);
  1000.       }
  1001.  
  1002.       if (this.parseChar != '|' && this.parseChar != ',') {
  1003.          if (this.isSGML() && this.parseChar == '&') {
  1004.             this.parseError(new ParserException(102, '&', 1), false);
  1005.             var1 = '|';
  1006.             this.skipWhite();
  1007.          } else if (this.parseChar != ')' && this.parseChar != '\uffff') {
  1008.             throw new ParserException(48, this.parseChar);
  1009.          }
  1010.       } else {
  1011.          var1 = this.parseChar;
  1012.          this.skipWhite();
  1013.       }
  1014.  
  1015.       this.factory.createCMTerm(var4, var2, var1);
  1016.       return var1;
  1017.    }
  1018.  
  1019.    void parseAttListDecl() throws ParserException {
  1020.       Vector var1 = null;
  1021.       this.skipWhite();
  1022.       if (this.isSGML() && this.parseChar == '#') {
  1023.          this.read();
  1024.          String var3 = this.parseName();
  1025.          throw new ParserException(118, String.valueOf('#').concat(String.valueOf(var3)), 1);
  1026.       } else {
  1027.          String var2;
  1028.          if (this.isSGML() && this.parseChar == '(') {
  1029.             var1 = this.parseNameList();
  1030.             var2 = (String)var1.firstElement();
  1031.          } else {
  1032.             var2 = this.parseName();
  1033.          }
  1034.  
  1035.          this.parseAttList(var2, var1);
  1036.       }
  1037.    }
  1038.  
  1039.    void parseInlineComment(boolean var1) throws ParserException {
  1040.       this.read();
  1041.       if (this.parseChar != '-') {
  1042.          throw new ParserException(114, this.parseChar);
  1043.       } else {
  1044.          this.parseInlineCommentInterior(var1);
  1045.       }
  1046.    }
  1047.  
  1048.    private void parseInlineCommentInterior(boolean var1, boolean var2) throws ParserException {
  1049.       boolean var3 = this.autoInsertPEs;
  1050.       this.autoInsertPEs = false;
  1051.  
  1052.       try {
  1053.          String var4 = this.parseUntil("--");
  1054.          this.factory.createComment(var4, var1);
  1055.          this.read();
  1056.          this.autoInsertPEs = true;
  1057.          if (var2) {
  1058.             this.checkWhite(true);
  1059.          }
  1060.       } finally {
  1061.          this.autoInsertPEs = var3;
  1062.       }
  1063.  
  1064.    }
  1065.  
  1066.    private void parseInlineCommentInterior(boolean var1) throws ParserException {
  1067.       this.parseInlineCommentInterior(var1, true);
  1068.    }
  1069.  
  1070.    void parseAttList(String var1, Vector var2) throws ParserException {
  1071.       boolean var4 = true;
  1072.       boolean var5 = false;
  1073.       this.checkWhite(true);
  1074.  
  1075.       while(this.parseChar != '>') {
  1076.          if (this.peStart != null) {
  1077.             if (this.factory.createAttributeGroup(this.peStart.getName(), var1)) {
  1078.                this.popReaderContext(this.peStart, true);
  1079.                this.peStart = null;
  1080.                this.checkWhite(true);
  1081.                continue;
  1082.             }
  1083.  
  1084.             this.checkWhite();
  1085.          }
  1086.  
  1087.          Object var7 = null;
  1088.          Vector var8 = null;
  1089.          if (this.isSGML() && this.parseChar == '-') {
  1090.             if (var4) {
  1091.                var5 = true;
  1092.             }
  1093.  
  1094.             this.parseInlineComment(var5);
  1095.             this.checkWhite(true);
  1096.          } else {
  1097.             String var9 = this.parseName();
  1098.             this.checkWhite();
  1099.  
  1100.             for(; this.parseChar == '-' && this.tryRead("--"); this.parseInlineCommentInterior(var5)) {
  1101.                if (var4) {
  1102.                   var5 = true;
  1103.                }
  1104.             }
  1105.  
  1106.             if (this.parseChar == '(') {
  1107.                byte var6 = 10;
  1108.                var7 = new Integer(var6);
  1109.                var8 = this.parseEnumeration();
  1110.             } else {
  1111.                this.checkWhite();
  1112.                if (this.peStart != null && DTDUtilities.isValidName(this.peStart.getName())) {
  1113.                   var7 = new String(this.peStart.getName());
  1114.                   this.popReaderContext(this.peStart, true);
  1115.                   this.peStart = null;
  1116.                   this.checkWhite();
  1117.                } else {
  1118.                   String var10 = this.parseCaps();
  1119.                   byte var12;
  1120.                   if (var10.equals("CDATA")) {
  1121.                      var12 = 1;
  1122.                   } else if (var10.equals("ID")) {
  1123.                      var12 = 2;
  1124.                   } else if (var10.equals("IDREF")) {
  1125.                      var12 = 3;
  1126.                   } else if (var10.equals("IDREFS")) {
  1127.                      var12 = 4;
  1128.                   } else if (var10.equals("ENTITY")) {
  1129.                      var12 = 5;
  1130.                   } else if (var10.equals("ENTITIES")) {
  1131.                      var12 = 6;
  1132.                   } else if (var10.equals("NMTOKEN")) {
  1133.                      var12 = 7;
  1134.                   } else if (var10.equals("NMTOKENS")) {
  1135.                      var12 = 8;
  1136.                   } else if (var10.equals("NOTATION")) {
  1137.                      this.checkWhite();
  1138.                      if (this.parseChar != '(') {
  1139.                         throw new ParserException(58, this.parseChar);
  1140.                      }
  1141.  
  1142.                      var12 = 9;
  1143.                      var8 = this.parseNotationType();
  1144.                   } else {
  1145.                      if (!this.isSGML()) {
  1146.                         throw new ParserException(56, var10);
  1147.                      }
  1148.  
  1149.                      if (var10.equals("NUMBER")) {
  1150.                         var12 = 1;
  1151.                         this.parseError(new ParserException(106, var10, 0), false);
  1152.                      } else if (var10.equals("NUMBERS")) {
  1153.                         var12 = 1;
  1154.                         this.parseError(new ParserException(106, var10, 0), false);
  1155.                      } else if (var10.equals("NUTOKEN")) {
  1156.                         var12 = 7;
  1157.                         this.parseError(new ParserException(107, var10, 0), false);
  1158.                      } else if (var10.equals("NAME")) {
  1159.                         var12 = 7;
  1160.                         this.parseError(new ParserException(107, var10, 0), false);
  1161.                      } else if (var10.equals("NUTOKENS")) {
  1162.                         var12 = 8;
  1163.                         this.parseError(new ParserException(108, var10, 0), false);
  1164.                      } else {
  1165.                         if (!var10.equals("NAMES")) {
  1166.                            throw new ParserException(56, var10);
  1167.                         }
  1168.  
  1169.                         var12 = 8;
  1170.                         this.parseError(new ParserException(108, var10, 0), false);
  1171.                      }
  1172.                   }
  1173.  
  1174.                   if (var7 == null) {
  1175.                      var7 = new Integer(var12);
  1176.                   }
  1177.                }
  1178.             }
  1179.  
  1180.             this.checkWhite();
  1181.  
  1182.             for(; this.isSGML() && this.parseChar == '-' && this.tryRead("--"); this.parseInlineCommentInterior(var5)) {
  1183.                if (var4) {
  1184.                   var5 = true;
  1185.                }
  1186.             }
  1187.  
  1188.             AttrDefaultInfo var13 = this.parseAttrDefault();
  1189.             if (var8 == null) {
  1190.                this.factory.createAttrDecl(var1, var9, var7, var13.req, var13.def, this.readerContext.getURI());
  1191.             } else {
  1192.                this.factory.createAttrDecl(var1, var9, var7, var8, var13.req, var13.def, this.readerContext.getURI());
  1193.             }
  1194.  
  1195.             if (this.isSGML() && var2 != null) {
  1196.                for(int var11 = 1; var11 < var2.size(); ++var11) {
  1197.                   this.factory.cloneAttrDecl(var9, var1, (String)var2.elementAt(var11));
  1198.                }
  1199.  
  1200.                this.parseError(new ParserException(105, var2.toString(), 0), false);
  1201.             }
  1202.  
  1203.             this.checkWhite(true);
  1204.             var4 = false;
  1205.          }
  1206.       }
  1207.  
  1208.    }
  1209.  
  1210.    AttrDefaultInfo parseAttrDefault() throws ParserException {
  1211.       AttrDefaultInfo var1 = new AttrDefaultInfo((DTDParser)null);
  1212.       if (this.parseChar == '#') {
  1213.          this.read();
  1214.          String var2 = this.parseCaps();
  1215.          if (var2.equals("REQUIRED")) {
  1216.             var1.req = true;
  1217.          } else if (var2.equals("IMPLIED")) {
  1218.             var1.req = false;
  1219.          } else if (var2.equals("FIXED")) {
  1220.             var1.req = true;
  1221.             this.skipWhite();
  1222.             if (this.parseChar == '>') {
  1223.                throw new ParserException(10, this.parseChar);
  1224.             }
  1225.  
  1226.             var1.def = this.parseAttValue();
  1227.             if (var1.def.indexOf("#CONTENT") == 0) {
  1228.                this.factory.createComment(var1.def, true);
  1229.                this.parseError(new ParserException(120, var1.def, 1), false);
  1230.                var1.def = null;
  1231.             }
  1232.          } else {
  1233.             if ((!this.isSGML() || !var2.equals("CURRENT")) && !var2.equals("CONREF")) {
  1234.                throw new ParserException(60, var2);
  1235.             }
  1236.  
  1237.             var1.req = false;
  1238.             this.parseError(new ParserException(116, String.valueOf('#').concat(String.valueOf(var2)), 0), false);
  1239.          }
  1240.       } else {
  1241.          if (this.parseChar == '>') {
  1242.             throw new ParserException(10, this.parseChar);
  1243.          }
  1244.  
  1245.          var1.def = this.parseAttValue();
  1246.       }
  1247.  
  1248.       return var1;
  1249.    }
  1250.  
  1251.    Vector parseEnumeration() throws ParserException {
  1252.       return this.parseEnumeration(false);
  1253.    }
  1254.  
  1255.    Vector parseEnumeration(boolean var1) throws ParserException {
  1256.       Vector var2 = new Vector();
  1257.       this.autoInsertPEs = false;
  1258.  
  1259.       try {
  1260.          this.skipWhite();
  1261.  
  1262.          while(true) {
  1263.             String var3;
  1264.             if (this.parseChar == '%') {
  1265.                this.read();
  1266.                String var4 = this.parseName();
  1267.                if (this.parseChar == ';') {
  1268.                   this.read();
  1269.                } else {
  1270.                   this.parseError(new ParserException(110, this.parseChar, 1), false);
  1271.                }
  1272.  
  1273.                var3 = String.valueOf(String.valueOf('%').concat(String.valueOf(var4))).concat(String.valueOf(';'));
  1274.             } else {
  1275.                var3 = var1 ? this.parseName() : this.parseNMToken();
  1276.             }
  1277.  
  1278.             var2.addElement(var3);
  1279.             this.checkWhite();
  1280.             if (this.parseChar != '|') {
  1281.                if (this.parseChar != ')') {
  1282.                   throw new ParserException(59, this.parseChar);
  1283.                }
  1284.  
  1285.                this.skipWhite();
  1286.                return var2;
  1287.             }
  1288.  
  1289.             this.skipWhite(true);
  1290.          }
  1291.       } finally {
  1292.          this.autoInsertPEs = true;
  1293.       }
  1294.    }
  1295.  
  1296.    Vector parseNotationType() throws ParserException {
  1297.       return this.parseEnumeration(true);
  1298.    }
  1299.  
  1300.    int parseEntityValuePrefix() throws ParserException {
  1301.       byte var1 = 0;
  1302.       if (this.parseChar != '"' && this.parseChar != '\'') {
  1303.          if (this.tryRead("SDATA")) {
  1304.             var1 = 1;
  1305.          } else if (this.tryRead("CDATA")) {
  1306.             var1 = 2;
  1307.          } else if (this.tryRead("PI")) {
  1308.             var1 = 3;
  1309.          } else if (this.tryRead("STARTTAG")) {
  1310.             var1 = 4;
  1311.          } else if (this.tryRead("ENDTAG")) {
  1312.             var1 = 5;
  1313.          } else if (this.tryRead("MD")) {
  1314.             var1 = 6;
  1315.          } else if (this.tryRead("MS")) {
  1316.             var1 = 7;
  1317.          }
  1318.       }
  1319.  
  1320.       if (var1 != 0) {
  1321.          this.skipWhite();
  1322.       }
  1323.  
  1324.       return var1;
  1325.    }
  1326.  
  1327.    void parseEntityDecl() throws ParserException {
  1328.       this.autoInsertPEs = false;
  1329.       this.skipWhite();
  1330.       this.autoInsertPEs = true;
  1331.       boolean var1 = this.parseChar == '%';
  1332.       if (var1) {
  1333.          this.skipWhite();
  1334.       }
  1335.  
  1336.       if (this.isSGML() && this.parseChar == '#') {
  1337.          if (this.tryRead("#DEFAULT")) {
  1338.             throw new ParserException(127, "#DEFAULT");
  1339.          } else if (this.tryRead("#default")) {
  1340.             throw new ParserException(127, "#DEFAULT");
  1341.          } else {
  1342.             this.read();
  1343.             throw new ParserException(129, this.parseName());
  1344.          }
  1345.       } else {
  1346.          String var2 = this.parseName();
  1347.          this.skipWhite();
  1348.  
  1349.          while(this.isSGML() && this.parseChar == '-' && this.tryRead("--")) {
  1350.             this.parseInlineCommentInterior(true);
  1351.          }
  1352.  
  1353.          int var3 = 0;
  1354.          if (this.isSGML()) {
  1355.             var3 = this.parseEntityValuePrefix();
  1356.          }
  1357.  
  1358.          while(this.parseChar == '-' && this.tryRead("--")) {
  1359.             this.parseInlineCommentInterior(true);
  1360.          }
  1361.  
  1362.          if (this.parseChar != '"' && this.parseChar != '\'') {
  1363.             LocRefInfo var5 = this.parseLocRefInfo(var1, false);
  1364.             if (var1) {
  1365.                this.factory.createParamEntityDecl(var2, var5.pubName, new URI(this.documentURI, var5.sysName), this.readerContext.getURI());
  1366.             } else if (var5.notation != null) {
  1367.                this.factory.createUnparsedEntityDecl(var2, var5.pubName, new URI(this.documentURI, var5.sysName), var5.notation, this.readerContext.getURI());
  1368.             } else {
  1369.                this.externalGEs.put(var2, var5.sysName);
  1370.                this.factory.createGeneralEntityDecl(var2, var5.pubName, new URI(this.documentURI, var5.sysName), this.readerContext.getURI());
  1371.             }
  1372.          } else {
  1373.             String var4 = this.parseEntityValue();
  1374.             if (this.isSGML() && var3 != 0) {
  1375.                switch (var3) {
  1376.                   case 1:
  1377.                      this.parseError(new ParserException(117, var4, 1), false);
  1378.                      break;
  1379.                   case 2:
  1380.                      this.parseError(new ParserException(121, var4, 1), false);
  1381.                      break;
  1382.                   case 3:
  1383.                      this.parseError(new ParserException(122, var4, 1), false);
  1384.                      break;
  1385.                   case 4:
  1386.                      this.parseError(new ParserException(123, var4, 1), false);
  1387.                      var4 = String.valueOf(String.valueOf('<').concat(String.valueOf(var4))).concat(String.valueOf('>'));
  1388.                      break;
  1389.                   case 5:
  1390.                      this.parseError(new ParserException(124, var4, 1), false);
  1391.                      var4 = String.valueOf(String.valueOf("</").concat(String.valueOf(var4))).concat(String.valueOf('>'));
  1392.                      break;
  1393.                   case 6:
  1394.                      this.parseError(new ParserException(125, var4, 1), false);
  1395.                      var4 = String.valueOf(String.valueOf("<![").concat(String.valueOf(var4))).concat(String.valueOf("]]>"));
  1396.                      break;
  1397.                   case 7:
  1398.                      this.parseError(new ParserException(126, var4, 1), false);
  1399.                      var4 = String.valueOf(String.valueOf("<!").concat(String.valueOf(var4))).concat(String.valueOf('>'));
  1400.                }
  1401.             }
  1402.  
  1403.             if (var1) {
  1404.                this.factory.createParamEntityDecl(var2, var4, this.readerContext.getURI());
  1405.             } else {
  1406.                this.internalGEs.put(var2, var4);
  1407.                this.factory.createGeneralEntityDecl(var2, var4, this.readerContext.getURI());
  1408.             }
  1409.          }
  1410.  
  1411.       }
  1412.    }
  1413.  
  1414.    LocRefInfo parseLocRefInfo(boolean var1, boolean var2) throws ParserException {
  1415.       LocRefInfo var3 = new LocRefInfo((DTDParser)null);
  1416.       String var4 = this.parseCaps();
  1417.       if (var4.equals("PUBLIC")) {
  1418.          this.checkWhite();
  1419.          var3.pubName = this.parsePubIdLiteral();
  1420.          if (this.isSGML() && this.parseChar == '-') {
  1421.             this.parseInlineComment(true);
  1422.          }
  1423.  
  1424.          if (this.parseChar != '>') {
  1425.             var3.sysName = this.parseSystemLiteral();
  1426.          } else if (var2) {
  1427.             var3.sysName = "";
  1428.          } else if (var1) {
  1429.             var3.sysName = "";
  1430.             if (!this.isSGML()) {
  1431.                throw new ParserException(76, this.parseChar);
  1432.             }
  1433.  
  1434.             this.parseError(new ParserException(109, this.parseChar, 1), false);
  1435.          }
  1436.       } else {
  1437.          if (!var4.equals("SYSTEM")) {
  1438.             throw new ParserException(76, var4);
  1439.          }
  1440.  
  1441.          this.checkWhite();
  1442.          var3.sysName = this.parseSystemLiteral();
  1443.       }
  1444.  
  1445.       this.checkWhite();
  1446.       if (!var1 && !var2) {
  1447.          if (this.tryRead("NDATA")) {
  1448.             this.skipWhite();
  1449.             var3.notation = this.parseName();
  1450.          } else if (this.tryRead("SUBDOC")) {
  1451.             this.parseError(new ParserException(128, "SUBDOC", 0), false);
  1452.             this.skipWhite();
  1453.          } else if (this.tryRead("CDATA")) {
  1454.             this.parseError(new ParserException(128, "CDATA", 0), false);
  1455.             this.skipWhite();
  1456.             this.parseName();
  1457.          } else if (this.tryRead("SDATA")) {
  1458.             this.parseError(new ParserException(128, "SDATA", 0), false);
  1459.             this.skipWhite();
  1460.             this.parseName();
  1461.          }
  1462.       }
  1463.  
  1464.       return var3;
  1465.    }
  1466.  
  1467.    void parseNotationDecl() throws ParserException {
  1468.       this.skipWhite();
  1469.       String var1 = this.parseName();
  1470.       this.skipWhite();
  1471.       if (this.peStart != null) {
  1472.       }
  1473.  
  1474.       LocRefInfo var2 = this.parseLocRefInfo(false, true);
  1475.       this.factory.createNotationDecl(var1, var2.pubName, var2.sysName.length() == 0 ? null : new URI(this.documentURI, var2.sysName), this.readerContext.getURI());
  1476.    }
  1477.  
  1478.    char checkWhite(boolean var1) throws ParserException {
  1479.       return this.parseChar != ' ' && this.parseChar != '\t' && this.parseChar != '\n' && this.parseChar != '\r' ? this.parseChar : this.skipWhite(var1);
  1480.    }
  1481.  
  1482.    char skipWhite(boolean var1) throws ParserException {
  1483.       this.read();
  1484.  
  1485.       while((this.parseChar == ' ' || this.parseChar == '\t' || this.parseChar == '\n' || this.parseChar == '\r') && (this.peStart == null || !var1)) {
  1486.          this.read();
  1487.       }
  1488.  
  1489.       return this.parseChar;
  1490.    }
  1491.  
  1492.    char checkWhite() throws ParserException {
  1493.       return this.parseChar != ' ' && this.parseChar != '\t' && this.parseChar != '\n' && this.parseChar != '\r' ? this.parseChar : this.skipWhite();
  1494.    }
  1495.  
  1496.    char skipWhite() throws ParserException {
  1497.       this.read();
  1498.  
  1499.       while(this.parseChar == ' ' || this.parseChar == '\t' || this.parseChar == '\n' || this.parseChar == '\r') {
  1500.          this.read();
  1501.       }
  1502.  
  1503.       return this.parseChar;
  1504.    }
  1505.  
  1506.    void trimWhite(StringBuffer var1) {
  1507.       int var2 = var1.length();
  1508.       if (var2 > 0) {
  1509.          switch (var1.charAt(var2 - 1)) {
  1510.             case '\t':
  1511.             case '\n':
  1512.             case '\r':
  1513.             case ' ':
  1514.                var1.setLength(var2--);
  1515.             default:
  1516.          }
  1517.       }
  1518.    }
  1519.  
  1520.    String parseTermName() throws ParserException {
  1521.       StringBuffer var1 = new StringBuffer();
  1522.       if (this.peStart != null) {
  1523.       }
  1524.  
  1525.       if (isNameStartChar(this.parseChar) || this.parseChar == '#' || this.supportsExtendedModelSyntax() && this.parseChar == ContentModelTerm.TAG_TYPE_SEPARATOR) {
  1526.          var1.append(this.parseChar);
  1527.          this.read();
  1528.  
  1529.          while(this.parseChar != '\uffff' && (isNameChar(this.parseChar) || this.supportsExtendedModelSyntax() && this.parseChar == ContentModelTerm.TAG_TYPE_SEPARATOR)) {
  1530.             var1.append(this.parseChar);
  1531.             this.read();
  1532.          }
  1533.       }
  1534.  
  1535.       return var1.toString();
  1536.    }
  1537.  
  1538.    String parseName() throws ParserException {
  1539.       StringBuffer var1 = new StringBuffer();
  1540.       if (this.peStart != null) {
  1541.       }
  1542.  
  1543.       if (isNameStartChar(this.parseChar)) {
  1544.          var1.append(this.parseChar);
  1545.          this.read();
  1546.  
  1547.          while(isNameChar(this.parseChar)) {
  1548.             var1.append(this.parseChar);
  1549.             this.read();
  1550.          }
  1551.       }
  1552.  
  1553.       return var1.toString();
  1554.    }
  1555.  
  1556.    String parseNMToken() throws ParserException {
  1557.       StringBuffer var1 = new StringBuffer();
  1558.       if (this.peStart != null) {
  1559.       }
  1560.  
  1561.       while(isNameChar(this.parseChar)) {
  1562.          var1.append(this.parseChar);
  1563.          this.read();
  1564.       }
  1565.  
  1566.       return var1.toString();
  1567.    }
  1568.  
  1569.    String parseAttValue() throws ParserException {
  1570.       StringBuffer var1 = new StringBuffer();
  1571.  
  1572.       String var4;
  1573.       try {
  1574.          this.autoInsertPEs = false;
  1575.          int var2 = this.readerStack.size();
  1576.          if (this.peStart != null) {
  1577.          }
  1578.  
  1579.          if (this.parseChar == '"' || this.parseChar == '\'') {
  1580.             char var9 = this.parseChar;
  1581.             this.read();
  1582.  
  1583.             while(this.parseChar != var9 || this.readerStack.size() != var2) {
  1584.                if (this.parseChar == '&') {
  1585.                   this.read();
  1586.                   var4 = this.parseName();
  1587.                   if (this.parseChar == ';') {
  1588.                      this.read();
  1589.                   } else {
  1590.                      if (!this.isSGML()) {
  1591.                         throw new ParserException(90, this.parseChar);
  1592.                      }
  1593.  
  1594.                      this.parseError(new ParserException(110, this.parseChar, 1), false);
  1595.                   }
  1596.  
  1597.                   var1.append(String.valueOf(String.valueOf('&').concat(String.valueOf(var4))).concat(String.valueOf(';')));
  1598.                } else {
  1599.                   var1.append(this.parseChar);
  1600.                   this.read();
  1601.                }
  1602.             }
  1603.  
  1604.             this.read();
  1605.             var4 = var1.toString();
  1606.             return var4;
  1607.          }
  1608.  
  1609.          if (!this.isSGML()) {
  1610.             throw new ParserException(10, this.parseChar);
  1611.          }
  1612.  
  1613.          String var3 = this.parseNMToken();
  1614.          this.parseError(new ParserException(113, var3, 0), false);
  1615.          var4 = var3;
  1616.       } finally {
  1617.          this.autoInsertPEs = true;
  1618.       }
  1619.  
  1620.       return var4;
  1621.    }
  1622.  
  1623.    String parseCaps() throws ParserException {
  1624.       StringBuffer var1 = new StringBuffer();
  1625.       if (this.isSGML()) {
  1626.          while(this.parseChar >= 'A' && this.parseChar <= 'Z' || this.parseChar >= 'a' && this.parseChar <= 'z') {
  1627.             var1.append(this.parseChar);
  1628.             this.read();
  1629.          }
  1630.  
  1631.          String var2 = var1.toString();
  1632.          return var2.toUpperCase();
  1633.       } else {
  1634.          while(this.parseChar >= 'A' && this.parseChar <= 'Z') {
  1635.             var1.append(this.parseChar);
  1636.             this.read();
  1637.          }
  1638.  
  1639.          return var1.toString();
  1640.       }
  1641.    }
  1642.  
  1643.    String parseQuote(char var1) throws ParserException {
  1644.       int var2 = this.readerStack.size();
  1645.       StringBuffer var3 = new StringBuffer();
  1646.       this.read();
  1647.  
  1648.       while(this.parseChar != var1 || this.readerStack.size() != var2) {
  1649.          var3.append(this.parseChar);
  1650.          this.read();
  1651.       }
  1652.  
  1653.       this.skipWhite();
  1654.       return var3.toString();
  1655.    }
  1656.  
  1657.    String parseUntil(String var1) throws ParserException {
  1658.       boolean var2 = var1.equals("-->");
  1659.       int var3 = this.readerStack.size();
  1660.       int var4 = 0;
  1661.       StringBuffer var5 = new StringBuffer();
  1662.  
  1663.       while(var4 < var1.length()) {
  1664.          this.read();
  1665.          if (this.parseChar == var1.charAt(var4) && this.readerStack.size() == var3) {
  1666.             ++var4;
  1667.          } else {
  1668.             if (var4 > 0) {
  1669.                var5.append(var1.substring(0, var4));
  1670.                var4 = 0;
  1671.             }
  1672.  
  1673.             var5.append(this.parseChar);
  1674.          }
  1675.       }
  1676.  
  1677.       return var5.toString();
  1678.    }
  1679.  
  1680.    String parsePubIdLiteral() throws ParserException {
  1681.       if (this.peStart != null) {
  1682.       }
  1683.  
  1684.       if (this.parseChar != '"' && this.parseChar != '\'') {
  1685.          throw new ParserException(12, this.parseChar);
  1686.       } else {
  1687.          return this.parseQuote(this.parseChar);
  1688.       }
  1689.    }
  1690.  
  1691.    String parseSystemLiteral() throws ParserException {
  1692.       if (this.peStart != null) {
  1693.       }
  1694.  
  1695.       if (this.parseChar != '"' && this.parseChar != '\'') {
  1696.          throw new ParserException(11, this.parseChar);
  1697.       } else {
  1698.          return this.parseQuote(this.parseChar);
  1699.       }
  1700.    }
  1701.  
  1702.    String parseEntityValue() throws ParserException {
  1703.       int var1 = this.readerStack.size();
  1704.       if (this.parseChar != '"' && this.parseChar != '\'') {
  1705.          throw new ParserException(8, this.parseChar);
  1706.       } else {
  1707.          char var2 = this.parseChar;
  1708.          StringBuffer var3 = new StringBuffer();
  1709.          this.autoInsertPEs = false;
  1710.  
  1711.          String var4;
  1712.          try {
  1713.             this.read();
  1714.  
  1715.             while(this.parseChar != var2) {
  1716.                while(this.isSGML() && this.parseChar == '-' && this.tryRead("--")) {
  1717.                   this.parseInlineCommentInterior(true, false);
  1718.                }
  1719.  
  1720.                var3.append(this.parseChar);
  1721.                this.read();
  1722.             }
  1723.  
  1724.             this.autoInsertPEs = true;
  1725.             this.skipWhite();
  1726.             var4 = var3.toString();
  1727.          } finally {
  1728.             this.autoInsertPEs = true;
  1729.          }
  1730.  
  1731.          return var4;
  1732.       }
  1733.    }
  1734.  
  1735.    boolean tryRead(String var1) throws ParserException {
  1736.       try {
  1737.          if (this.parseChar != var1.charAt(0)) {
  1738.             boolean var6 = false;
  1739.             return var6;
  1740.          } else {
  1741.             this.readerContext.mark(var1.length());
  1742.             int var2 = 1;
  1743.             if (this.isSGML()) {
  1744.                while(var2 < var1.length()) {
  1745.                   if (Character.toUpperCase((char)this.readerContext.read()) != Character.toUpperCase(var1.charAt(var2++))) {
  1746.                      this.readerContext.reset();
  1747.                      boolean var8 = false;
  1748.                      return var8;
  1749.                   }
  1750.                }
  1751.             } else {
  1752.                while(var2 < var1.length()) {
  1753.                   if (this.readerContext.read() != var1.charAt(var2++)) {
  1754.                      this.readerContext.reset();
  1755.                      boolean var7 = false;
  1756.                      return var7;
  1757.                   }
  1758.                }
  1759.             }
  1760.  
  1761.             this.readerContext.reset();
  1762.  
  1763.             for(int var9 = 1; var9 < var1.length(); ++var9) {
  1764.                this.read();
  1765.             }
  1766.  
  1767.             boolean var4 = true;
  1768.             return var4;
  1769.          }
  1770.       } catch (IOException var5) {
  1771.          boolean var3 = false;
  1772.          return var3;
  1773.       }
  1774.    }
  1775.  
  1776.    void read() throws ParserException {
  1777.       try {
  1778.          Debug.assert(this.parseChar != -1, "Passed eof");
  1779.          if (this.peStart != null && !isWhiteChar(this.parseChar)) {
  1780.             StringBuffer var1 = new StringBuffer(this.currentSyntax.toString());
  1781.             this.currentSyntax.setLength(this.currentSyntax.length() - 1);
  1782.             this.currentSyntax.append(String.valueOf(String.valueOf("%").concat(String.valueOf(this.peStart.getName()))).concat(String.valueOf(";")));
  1783.             if (this.inIgnoreSection()) {
  1784.                this.ignoredText.setLength(this.ignoredText.length() - 1);
  1785.                this.ignoredText.append(String.valueOf(String.valueOf("%").concat(String.valueOf(this.peStart.getName()))).concat(String.valueOf(";")));
  1786.             }
  1787.  
  1788.             this.parseError(new ParserException(99, this.peStart.getName(), 1), false);
  1789.             this.currentSyntax = var1;
  1790.             this.peStart = null;
  1791.          }
  1792.  
  1793.          this.parseChar = (char)this.readerContext.read();
  1794.          if (this.parseChar == '\uffff') {
  1795.             this.popReaderContext((ReaderContext)null, false);
  1796.          } else {
  1797.             ++this.charsParsedSoFar;
  1798.             this.currentSyntax.append(this.parseChar);
  1799.             if (this.inIgnoreSection()) {
  1800.                this.ignoredText.append(this.parseChar);
  1801.             }
  1802.  
  1803.             if (this.autoInsertGEs && this.parseChar == '&') {
  1804.                int var5 = this.currentSyntax.length() - 1;
  1805.                this.parseGEReference(true, false);
  1806.                if (this.parseChar == ';') {
  1807.                   this.read();
  1808.                }
  1809.  
  1810.                this.currentSyntax.setLength(var5);
  1811.             } else if (this.autoInsertPEs && this.parseChar == '%') {
  1812.                int var4 = this.currentSyntax.length() - 1;
  1813.                String var2 = this.parsePEReference(false);
  1814.                this.currentSyntax.setLength(var4);
  1815.                this.currentSyntax.append(this.parseChar);
  1816.                if (this.readerContext.getType() == 4) {
  1817.                   this.peStart = this.readerContext;
  1818.                }
  1819.             }
  1820.          }
  1821.  
  1822.       } catch (IOException var3) {
  1823.          throw new ParserException(var3, this.readerContext.getURI().getShortName());
  1824.       }
  1825.    }
  1826.  
  1827.    boolean isURI(String var1) {
  1828.       try {
  1829.          new URL(var1);
  1830.          boolean var2 = true;
  1831.          return var2;
  1832.       } catch (MalformedURLException var4) {
  1833.          boolean var3 = false;
  1834.          return var3;
  1835.       }
  1836.    }
  1837.  
  1838.    private void popReaderContext(ReaderContext var1, boolean var2) throws ParserException {
  1839.       this.peStart = null;
  1840.       if (var2) {
  1841.          this.currentSyntax.setLength(this.currentSyntax.length() - 1);
  1842.          if (this.inIgnoreSection()) {
  1843.             this.ignoredText.setLength(this.ignoredText.length() - 1);
  1844.          }
  1845.       }
  1846.  
  1847.       ReaderContext var3 = this.readerContext;
  1848.       this.readerContext.close();
  1849.       if (!this.readerStack.empty()) {
  1850.          if (this.readerContext.getType() == 5) {
  1851.             this.factory.createExternalSubsetClose();
  1852.          }
  1853.  
  1854.          this.readerContext = (ReaderContext)this.readerStack.pop();
  1855.          this.parseChar = 0;
  1856.          if (var1 != null && var3 != var1) {
  1857.             this.popReaderContext(var1, false);
  1858.          } else {
  1859.             this.read();
  1860.          }
  1861.  
  1862.       } else if (this.signalEOF) {
  1863.          throw new ParserException(new EOFException(), this.readerContext.getURI().toSource());
  1864.       }
  1865.    }
  1866.  
  1867.    public boolean statusIsDone() {
  1868.       return !this.inParser;
  1869.    }
  1870.  
  1871.    public long statusTotalCharsToParse() {
  1872.       return this.totalCharsToParse;
  1873.    }
  1874.  
  1875.    public long statusCharsParsedSoFar() {
  1876.       return this.charsParsedSoFar;
  1877.    }
  1878.  
  1879.    public String statusCurrentURI() {
  1880.       return this.readerContext == null ? "" : this.readerContext.getURI().getShortName();
  1881.    }
  1882. }
  1883.